<body>

<p>
Drools & jBPM provide an knowledge-centric API, where rules and processes are first class citizens.
</p>

<p>
The most common interfaces you will use are:
<ul>
<li><tt>org.drools.core.builder.KnowledgeBuilder</tt></li>
<li><tt>org.drools.KnowledgeBase</tt></li>
<li><tt>org.drools.agent.KnowledgeAgent</tt></li>
<li><tt>org.drools.core.runtime.StatefulKnowledgeSession</tt></li>
<li><tt>org.drools.core.runtime.StatelessKnowledgeSession</tt></li>
</ul>
</p>

<p>
Factory classes, with static methods, provide instances of the above interfaces. A pluggable provider approach is used to allow provider implementations to
be wired up to the factories at runtime. The Factories you will most commonly used are:
<ul>
<li><tt>org.drools.core.builder.KnowledgeBuilderFactory</tt></li>
<li><tt>org.drools.io.ResourceFactory</tt></li>
<li><tt>org.drools.KnowledgeBaseFactory</tt></li>
<li><tt>org.drools.agent.KnowledgeAgentFactory</tt></li>
</ul>
</p>

<p>
A Typical example to load a rule resource.
<pre>
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newUrlResource( url ),
                      ResourceType.DRL );
if ( kbuilder.hasErrors() ) {
    System.err.println( builder.getErrors().toString() );
}                     

KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( builder.getKnowledgePackages() );

StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();
ksession.insert( new Fibonacci( 10 ) );
ksession.fireAllRules();

ksession.dispose();
</pre>
</p>

<p>
A Typical example to load a process resource. Notice the ResourceType is changed to BPMN2 in this example.
<pre>
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newUrlResource( url ),
              ResourceType.BPMN2 );
KnowledgeBase kbase = kbuilder.newKnowledgeBase();
StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();
ksession.startProcess( "Buy Order Process" );
ksession.dispose();
</pre>
</p>

<p>
'kbuilder', 'kbase', 'ksession' are the variable identifiers often used, the k prefix is for 'knowledge'.
</p>

<p>
It is also possible to configure a KnowledgeBase using configuration, via a xml change set, instead of programmatically. Here is a simple change set:
</p>
<pre>
&lt;change-set xmlns='http://drools.org/drools-5.0/change-set'
           xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
           xs:schemaLocation='http://drools.org/drools-5.0/change-set change-set-5.0.xsd' &gt;
  &lt;add&gt;
    &lt;resource source='classpath:org/domain/someRules.drl' type='DRL' /&gt;
    &lt;resource source='classpath:org/domain/myProcess.bpmn2' type='BPMN2' /&gt;
  &lt;/add&gt;
&lt;/change-set&gt;
</pre>

<p>
And it is added just like any other ResourceType
</p>
<pre>
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newUrlResource( url ),
              ResourceType.ChangeSet );
</pre>

<p>
The majority of knowledge API is considered stable and should not change, experimental classes and API's will be marked as such.
</p>
</body>
